﻿@model WeddingEventManagementApp.Models.Dashboard_VM
@{
    ViewBag.Title = "Dashboard";
}

<div class="twelve columns">
    <div class="row">
        <div class="four columns">
            <a href="@Url.Action("Create", "Client")">
                <div class="card card-blue">
                    <h5>Add New Client</h5>
                    <i class="icon-user-3" style="font-size: 52px;position: absolute;right: 20px;top: 10px;"></i>
                </div>
            </a>
        </div>
        <div class="four columns">
            <a href="@Url.Action("Create", "Event")">
                <div class="card card-blue">
                    <h5>Add New Event</h5>
                    <i class="icon-calendar" style="font-size: 52px;position: absolute;right: 20px;top: 10px;"></i>
                </div>
            </a>
        </div>
        <div class="four columns">
            <a href="@Url.Action("Create", "Location")">
                <div class="card card-blue">
                    <h5>Add Location</h5>
                    <i class="icon-location" style="font-size: 52px;position: absolute;right: 20px;top: 10px;"></i>
                </div>
            </a>
        </div>
    </div>

</div>

<div class="seven columns">
    <h3><i class="icon-newspaper"></i> Activity Log</h3>
    <ul class="action-list no-bullet">
        @foreach (var group in Model.ActivityLog.GroupBy(m => m.DateTime.ToLocalTime().Date).OrderByDescending(m => m.Key))
        {
            <h5>@group.Key.ToString("MMM dd")</h5>
            foreach (var item in group.OrderByDescending(i => i.DateTime))
            {
                <li class="@item.Type @item.Action">
                    <i class="@item.Icon"></i>
                    <span class="user">@item.User</span> @Html.Raw(item.Action) <a href="@item.Object_URL">@item.Object</a>
                    <abbr class="timeago" title="@item.DateTime.ToString("s")z">@item.DateTime.ToString()</abbr>
                </li>
            }
            <li class="filler">
            </li>
	    }
    </ul>
</div>

<div class="five columns">
    <br>
    <dl class="tabs">
      <dd class="active"><a href="#tab1">Upcoming Events</a></dd>
      <dd><a href="#tab2">Invoices Due</a></dd>
    </dl>

    <ul class="tabs-content">
      <li id="tab1Tab" class="active">
          <ul class="event-list no-bullet">
              @foreach (var item in Model.UpcomingEvents)
              {
                  <li>
                    <a href="@Url.Action("Details", "Event" , new { id = item.EventID })" class="clearfix" style="border-color: @item.EventType.CalendarColor">
                        <span class="event-date" style="background: @item.EventType.CalendarColor">
                            <span class="event-dd">@item.StartDate.Day</span>
                            <span class="event-mm">@item.StartDate.ToString("MMM")</span>
                        </span>
                        <span class="event-title">
                            <p>@item.Title</p>
                            <span><i class="icon-clock"></i> @item.StartDate.ToShortTimeString()</span>
                        </span>
                    </a>
                </li>
              }
          </ul>
      </li>
      <li id="tab2Tab">
          <ul class="no-bullet" style="margin: 0;">
              @foreach (var item in Model.OutstandingInvoices)
              {
                  <li style="border: 1px dashed #aaa; padding: 4px 4px">
                    <a href="@Url.Action("Index", "Invoice", new { id = item.InvoiceID } )">
                        @{ decimal total = WeddingEventManagementApp.Utility.CalculateInvoiceTotal(item); }

                        @foreach (var payment in item.Payments)
                        {
                            total -= payment.Amount;
                        }

                        <h5 class="text-right"><span class="left">Invoice #@item.InvoiceID</span>Due: @item.DueDate.ToShortDateString()</h5>
                        <div class="text-right"><strong class="left" style="color: #444;">Balance:</strong><span style="color: #d30202">@total.ToString("c")</span></div>
                    </a>
                  </li>
              }
          </ul>
      </li>
    </ul>
</div>

